package com.hex.liyue.usermodule.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hex.liyue.R;
import com.hex.liyue.commonmodule.activity.BaseActivity;
import com.hex.liyue.commonmodule.manager.UserManager;
import com.hex.liyue.commonmodule.utils.StatusBarCompatUtils;
import com.hex.liyue.usermodule.presenter.FeedBackPresenter;
import com.hex.liyue.usermodule.presenter.IFeedBackVIew;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 这是一个意见反馈的界面
 * Created by yukoyuan on 16/6/18.
 */
public class FeedBackActivity extends BaseActivity implements IFeedBackVIew {
    @Bind(R.id.iv_toobar_back)
    ImageView ivToobarBack;
    @Bind(R.id.tv_toobar_title)
    TextView tvToobarTitle;
    @Bind(R.id.et_feedback_message)
    EditText etFeedbackMessage;
    @Bind(R.id.et_feedback_mobile)
    EditText etFeedbackMobile;
    private FeedBackPresenter feedBackPresenter;

    @Override
    protected void bindPresenter() {
        feedBackPresenter = new FeedBackPresenter(this);
    }

    @Override
    protected void initData(Bundle extras) {
        etFeedbackMobile.setText(UserManager.getUserPhone());
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_feedback;
    }

    @Override
    protected void initToolbar() {
        StatusBarCompatUtils.compat(this);
        ivToobarBack.setVisibility(View.VISIBLE);
        tvToobarTitle.setVisibility(View.VISIBLE);
        tvToobarTitle.setText("意见反馈");
    }


    @OnClick({R.id.iv_toobar_back, R.id.tv_feedback_submit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_toobar_back:
                onBackPressed();
                break;
            case R.id.tv_feedback_submit:
                feedBackPresenter.submit();
                break;
        }
    }

    @Override
    public String getFeedBackMessage() {
        return etFeedbackMessage.getText().toString().trim();
    }

    @Override
    public String getFeedBackMobile() {
       return  etFeedbackMobile.getText().toString().trim();
    }

    @Override
    public void closeCurrentActivity() {
        onBackPressed();
    }

    @Override
    public void showLod(String msg) {
        showLoad(this, msg);
    }

    @Override
    public void closeLod() {
        closeLoad();
        finish();
    }

    @Override
    public void showT(String msg) {
        showToast(this, msg);
    }


}
